package com.meihua.shellapp.activity.maker;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.meihua.shellapp.R;
import com.meihua.shellapp.adapter.personalcenter.MyFragmentPagerAdapter;
import com.meihua.shellapp.base.BaseActivity;
import com.meihua.shellapp.fragment.achievement.AchievementSelectFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;

/**
 * 业绩查询
 * 作者：lc on 2017/9/28.
 * 邮箱：lc0607live@163.com
 */

public class AchievementSelectActivity extends BaseActivity {

    @Bind(R.id.tl_achievementselect)
    TabLayout tl_achievementselect;//头部导航
    @Bind(R.id.vp_achievementselect)
    ViewPager vp_achievementselect;//内容
    @Bind(R.id.iv_top_left)
    ImageView iv_top_left;//返回
    @Bind(R.id.tv_title)
    TextView tv_title;//标题

    private List<Fragment> mFragment = new ArrayList<>();
    private MyFragmentPagerAdapter mAdapter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_achievementselect;
    }

    @Override
    public void initView(Bundle savedInstanceState) {
        tv_title.setText("业绩查询");
        iv_top_left.setVisibility(View.VISIBLE);
        tv_title.setVisibility(View.VISIBLE);
        List<String> type = new ArrayList<>();
        type.add("年险");
        type.add("寿险");
        type.add("其他保险");
        mFragment.add(new AchievementSelectFragment().setType(1));
        mFragment.add(new AchievementSelectFragment().setType(2));
        mFragment.add(new AchievementSelectFragment().setType(3));
        mAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager(), type, mFragment);
        vp_achievementselect.setAdapter(mAdapter);
        tl_achievementselect.setupWithViewPager(vp_achievementselect);
        LinearLayout linearLayout = (LinearLayout) tl_achievementselect.getChildAt(0);
        linearLayout.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
        linearLayout.setDividerDrawable(ContextCompat.getDrawable(this,
                R.drawable.bg_parting_ordertl));
        linearLayout.setDividerPadding((int) (getWH()[0] * (22 / 750.0)));
        iv_top_left.setOnClickListener(this);
    }
}
